package com.d3works.studio.db.repo;

import com.d3works.inject.Beans;
import com.d3works.studio.db.SelectionBuilder;
import com.d3works.studio.service.builder.SelectionBuilderService;

public class SelectionBuilderRepo extends SelectionBuilderRepository {

  @Override
  public SelectionBuilder save(SelectionBuilder selectionBuilder) {

    Beans.get(SelectionBuilderService.class).build(selectionBuilder);

    return super.save(selectionBuilder);
  }

  @Override
  public void remove(SelectionBuilder selectionBuilder) {

    Beans.get(SelectionBuilderService.class)
        .removeSelection(
            null,
            SelectionBuilderService.SELECTION_PREFIX
                + selectionBuilder.getName().replace(" ", "-"));

    super.remove(selectionBuilder);
  }
}
